package lumis.portal.incontextedit;

import lumis.portal.PortalException;
import lumis.portal.authentication.SessionConfig;
import lumis.portal.presentation.perspective.IPortalMode;
import lumis.portal.servicecontainer.ServiceContainerRenderRequest;
import lumis.portal.serviceinterfaceinstance.ServiceInterfaceInstanceConfig;
import lumis.util.ITransaction;

import org.apache.wicket.util.string.AppendingStringBuffer;

/**
 * In context edit handler. The implementations are responsible for dealing with
 * in context edit actions.
 * 
 * @version $Revision: 13214 $ $Date: 2011-07-07 21:46:10 -0300 (Thu, 07 Jul 2011) $
 * @since 6.0.1
 */
public interface IServiceInterfaceInContextEdit
{
	/**
	 * The interface instance in context edit attribute name;
	 * @since 6.0.1
	 */
	public static final String LUMIS_INTERFACE_IN_CONTEXT_EDIT_ATTRIBUTE_NAME = "lumis:interface-instance";

	/**
	 * Returns in context edit menu XML string for the given service interface
	 * instance.
	 * 
	 * @param sessionConfig
	 *            the session config.
	 * @param serviceInterfaceInstanceConfig
	 *            the interface instance config.
	 * @param detailsLumItemId
	 *            the lumItemId passed to the source page.
	 * @param transaction
	 *            the transaction.
	 * @return the service interface instance's in context edit menu's XML
	 *         string.
	 * @since 6.0.1
	 */
	public String getInContextEditMenu(SessionConfig sessionConfig,
			ServiceInterfaceInstanceConfig serviceInterfaceInstanceConfig, String detailsLumItemId,
			ITransaction transaction)
			throws PortalException;

	/**
	 * Returns in context edit menu XML string for the given content
	 * (represented by a version's item id).
	 * 
	 * @param sessionConfig
	 *            the session config.
	 * @param itemId
	 *            the item id.
	 * @param sourcePageId
	 *            the source page identifier.
	 * @param transaction
	 *            the transaction.
	 * @return in context edit menu XML string for the given content
	 *         (represented by a version's item id).
	 * @since 6.0.1
	 */
	public String getInContextEditMenu(SessionConfig sessionConfig, String itemId,
			String sourcePageId, ITransaction transaction) throws PortalException;

	/**
	 * Process in context edit content related attributes.
	 * 
	 * @param renderRequest
	 *            the request.
	 * @param serviceInterfaceInstanceConfig
	 *            the service interface instance.
	 * @param outputHTML
	 *            the HTML to be processed.
	 * @param transaction
	 *            the transaction.
	 * @return a processed version of HTML.
	 * @since 6.0.1
	 */
	public String processInContextEditContent(ServiceContainerRenderRequest renderRequest,
			ServiceInterfaceInstanceConfig serviceInterfaceInstanceConfig, String outputHTML,
			ITransaction transaction) throws PortalException;

	/**
	 * Removes in context editing interface instance related attributes if
	 * needed.
	 * 
	 * @param sessionConfig
	 *            the session config.
	 * @param portalMode
	 *            the portal mode.
	 * @param serviceInterfaceInstanceConfig
	 *            the interface instance.
	 * @param html
	 *            the HTML to be processed.
	 * @param sb
	 *            the String Buffer to store processed version of HTML.
	 * @param detailsLumItemId
	 *            the lumItemId passed to the details interface (if the
	 *            interface is details).
	 * @param transaction
	 *            the transaction.
	 * @return A boolean indicating if the interface instance attribute should
	 *         be added or not. Also, appends in string buffer the processed
	 *         version of HTML.
	 * @since 6.0.1
	 */
	public boolean removeInContextEditInterfaceInstance(SessionConfig sessionConfig,
			IPortalMode portalMode, ServiceInterfaceInstanceConfig serviceInterfaceInstanceConfig,
			String html, AppendingStringBuffer sb, String detailsLumItemId, ITransaction transaction)
			throws PortalException;
}
